#ifndef IMAGEDOWNLOADER_H
#define IMAGEDOWNLOADER_H

#include <QObject>
#include <QUrl>

class QNetworkReply;

namespace Jcr
{

class ImageDownloaderPrivate;
class ImageDownloader : public QObject
{
    Q_OBJECT
public:
    explicit ImageDownloader(const QUrl& url, const QString& saveDir, QObject *parent = 0);
    virtual ~ImageDownloader();

    void setSaveName(const QString& name);
    QString saveName() const;

    QString localPath() const;
    QUrl url() const;

public slots:
    virtual void run();

signals:
    void finished();

private slots:
    void onDownloadCompleted(QNetworkReply *reply);

private:
    Q_DISABLE_COPY(ImageDownloader)
    ImageDownloaderPrivate* d_ptr;
};

} // namespace jcr
#endif // IMAGEDOWNLOADER_H
